package com.spzx.product.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.RemoteProductService;
import com.spzx.product.api.model.ProductSku;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * 用户服务降级处理
 *
 * @author spzx
 */
//@Component
@Slf4j
public class RemoteProductFallbackFactory implements FallbackFactory<RemoteProductService> {


    @Override
    public RemoteProductService create(Throwable cause) {
        log.error("获取商品sku详情失败:{}",cause.getMessage());
        return new RemoteProductService(){
            public R<ProductSku> getProductSku(Long skuId, String header){
                return  R.fail("获取商品SKU详情失败"+cause.getMessage());
            }
        };

    }
}